/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPanelAltaAmigo.java
 *
 * Created on 5/05/2012, 01:54:47 AM
 */
package vista.panel;

import controlador.ControladorJPanelAltaAmigo;
import controlador.ControladorPrincipal;
import java.awt.event.KeyEvent;
import javax.swing.JTextField;
import modelo.Amigo;
import modelo.Lider;
import modelo.Seccion;

/**
 *
 * @author Elias Mendoza
 */
public class JPanelAltaAmigo extends javax.swing.JPanel {

    public static ControladorJPanelAltaAmigo accion = null;

    public static JPanelAltaAmigo panelAltaAmigo = null;

    private JPanelAltaAmigo(){
        initComponents();
        accion = new ControladorJPanelAltaAmigo(this);
        accion.llenarCombox();
    }

    public static JPanelAltaAmigo getPanelAltaAmigo() {
        if(panelAltaAmigo == null){
            System.out.println("creando una nueva instancia y objeto");
            panelAltaAmigo = new JPanelAltaAmigo();
        }
        else{
            System.out.println("ya se encontraba una instancia de la clase");
        }
        return panelAltaAmigo;
    }
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButtonRegistrar = new javax.swing.JButton();
        jButtonBorrar = new javax.swing.JButton();
        jTextFieldFolio = new javax.swing.JTextField();
        jTextFieldNombre = new javax.swing.JTextField();
        jTextFieldTelefono2 = new javax.swing.JTextField();
        jTextFieldApellidos = new javax.swing.JTextField();
        jTextFieldTelefono = new javax.swing.JTextField();
        jTextFieldDireccion = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jComboBoxLider = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jComboBoxSeccion = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPanelRegistro = new javax.swing.JTextPane();
        jButtonRefrescar = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));
        setLayout(new java.awt.GridBagLayout());

        jLabel1.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel1.setText("Folio");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jLabel1, gridBagConstraints);

        jLabel2.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel2.setText("Nombre:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jLabel2, gridBagConstraints);

        jLabel3.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel3.setText("Apellidos:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jLabel3, gridBagConstraints);

        jLabel4.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel4.setText("Telefono:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jLabel4, gridBagConstraints);

        jLabel5.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel5.setText("Telefono 2:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jLabel5, gridBagConstraints);

        jLabel6.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel6.setText("Dirección:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jLabel6, gridBagConstraints);

        jButtonRegistrar.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jButtonRegistrar.setText("Registrar");
        jButtonRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegistrarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        add(jButtonRegistrar, gridBagConstraints);

        jButtonBorrar.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jButtonBorrar.setText("Borrar");
        jButtonBorrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBorrarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.ipadx = 5;
        gridBagConstraints.ipady = 5;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
        add(jButtonBorrar, gridBagConstraints);

        jTextFieldFolio.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jTextFieldFolio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldFolioKeyTyped(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridy = 3;
        gridBagConstraints.ipadx = 40;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jTextFieldFolio, gridBagConstraints);

        jTextFieldNombre.setFont(new java.awt.Font("Times New Roman", 1, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.ipadx = 100;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jTextFieldNombre, gridBagConstraints);

        jTextFieldTelefono2.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jTextFieldTelefono2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldTelefono2KeyTyped(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.ipadx = 60;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jTextFieldTelefono2, gridBagConstraints);

        jTextFieldApellidos.setFont(new java.awt.Font("Times New Roman", 1, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.ipadx = 150;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jTextFieldApellidos, gridBagConstraints);

        jTextFieldTelefono.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jTextFieldTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldTelefonoKeyTyped(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 6;
        gridBagConstraints.ipadx = 60;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jTextFieldTelefono, gridBagConstraints);

        jTextFieldDireccion.setFont(new java.awt.Font("Times New Roman", 1, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.ipadx = 200;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 10, 0);
        add(jTextFieldDireccion, gridBagConstraints);

        jLabel7.setFont(new java.awt.Font("Calibri", 1, 18));
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("Registrar nuevo Amigo");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 5;
        gridBagConstraints.ipadx = 20;
        gridBagConstraints.ipady = 20;
        add(jLabel7, gridBagConstraints);

        jLabel8.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel8.setText("Lider");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 12;
        add(jLabel8, gridBagConstraints);

        jComboBoxLider.setFont(new java.awt.Font("Times New Roman", 1, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 12;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 100;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
        add(jComboBoxLider, gridBagConstraints);

        jLabel9.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabel9.setText("Sección");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.ipadx = 3;
        gridBagConstraints.ipady = 4;
        gridBagConstraints.insets = new java.awt.Insets(13, 0, 15, 0);
        add(jLabel9, gridBagConstraints);

        jComboBoxSeccion.setEditable(true);
        jComboBoxSeccion.setFont(new java.awt.Font("Times New Roman", 1, 12));
        jComboBoxSeccion.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 10;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.ipadx = 3;
        gridBagConstraints.ipady = 4;
        gridBagConstraints.insets = new java.awt.Insets(13, 0, 15, 0);
        add(jComboBoxSeccion, gridBagConstraints);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setLayout(new java.awt.GridBagLayout());

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS));

        jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Ult.Registro", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 10))); // NOI18N

        jTextPanelRegistro.setBorder(null);
        jTextPanelRegistro.setEditable(false);
        jTextPanelRegistro.setFont(new java.awt.Font("Times New Roman", 0, 10));
        jScrollPane1.setViewportView(jTextPanelRegistro);

        jPanel1.add(jScrollPane1);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 10;
        gridBagConstraints.ipadx = 100;
        gridBagConstraints.ipady = 100;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_START;
        gridBagConstraints.insets = new java.awt.Insets(60, 0, 7, 0);
        jPanel2.add(jPanel1, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 10;
        add(jPanel2, gridBagConstraints);

        jButtonRefrescar.setText("Refrescar");
        jButtonRefrescar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRefrescarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0);
        add(jButtonRefrescar, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents

  private void jButtonRegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegistrarActionPerformed
      // TODO add your handling code here:
      accion.registrarAmigo();
  }//GEN-LAST:event_jButtonRegistrarActionPerformed

  private void jTextFieldTelefonoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldTelefonoKeyTyped
      // TODO add your handling code here:
      if ((int) evt.getKeyChar() >= 48 && (int) evt.getKeyChar() <= 57) {
      } else {
          evt.setKeyChar((char) KeyEvent.VK_CLEAR);
      }
  }//GEN-LAST:event_jTextFieldTelefonoKeyTyped

  private void jTextFieldFolioKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldFolioKeyTyped
      // TODO add your handling code here:
      if ((int) evt.getKeyChar() >= 48 && (int) evt.getKeyChar() <= 57) {
      } else {
          evt.setKeyChar((char) KeyEvent.VK_CLEAR);
      }
  }//GEN-LAST:event_jTextFieldFolioKeyTyped

  private void jTextFieldTelefono2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldTelefono2KeyTyped
      // TODO add your handling code here:
      if ((int) evt.getKeyChar() >= 48 && (int) evt.getKeyChar() <= 57) {
      } else {
          evt.setKeyChar((char) KeyEvent.VK_CLEAR);
      }
  }//GEN-LAST:event_jTextFieldTelefono2KeyTyped

  private void jButtonBorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBorrarActionPerformed
      // TODO add your handling code here:
  }//GEN-LAST:event_jButtonBorrarActionPerformed

private void jButtonRefrescarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRefrescarActionPerformed
// TODO add your handling code here:
    accion.llenarCombox();
}//GEN-LAST:event_jButtonRefrescarActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton jButtonBorrar;
    public javax.swing.JButton jButtonRefrescar;
    public javax.swing.JButton jButtonRegistrar;
    public javax.swing.JComboBox jComboBoxLider;
    public javax.swing.JComboBox jComboBoxSeccion;
    public javax.swing.JLabel jLabel1;
    public javax.swing.JLabel jLabel2;
    public javax.swing.JLabel jLabel3;
    public javax.swing.JLabel jLabel4;
    public javax.swing.JLabel jLabel5;
    public javax.swing.JLabel jLabel6;
    public javax.swing.JLabel jLabel7;
    public javax.swing.JLabel jLabel8;
    public javax.swing.JLabel jLabel9;
    public javax.swing.JPanel jPanel1;
    public javax.swing.JPanel jPanel2;
    public javax.swing.JScrollPane jScrollPane1;
    public javax.swing.JTextField jTextFieldApellidos;
    public javax.swing.JTextField jTextFieldDireccion;
    public javax.swing.JTextField jTextFieldFolio;
    public javax.swing.JTextField jTextFieldNombre;
    public javax.swing.JTextField jTextFieldTelefono;
    public javax.swing.JTextField jTextFieldTelefono2;
    public javax.swing.JTextPane jTextPanelRegistro;
    // End of variables declaration//GEN-END:variables
}
